<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateMortgageLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('mortgage_logs', function (Blueprint $table) {
            $table->id();

            $table->tinyInteger('status')->default(1)->comment('1未结清2已结清');
            $table->tinyInteger('is_month')->default(1)->comment('1本月2次月还款');
            $table->string('order_sn')->default('')->comment('订单编号');
            $table->string('mark')->default('')->comment('订单备注');
            $table->string('bank_name')->default('')->comment('按揭银行');
            $table->text('cars')->nullable()->comment('前端回显数据');
            $table->integer('days')->nullable()->comment('每月还款时间');

            $table->string('plate_numbers')->default('')->comment('车牌号');
            $table->integer('total_number')->default(0)->comment('按揭期数');
            $table->integer('all_number')->default(0)->comment('总还款期数');

            $table->integer('returned_number')->default(0)->comment('已还款期数');


            $table->decimal('total_amonut',10,2)->default(0.00)->comment('还款总金额');
            $table->decimal('mortgage_amount',10,2)->default(0.00)->comment('按揭总额');
            $table->decimal('interest',10,2)->default(0.00)->comment('还款总利息');
            $table->decimal('return_amount',10,2)->default(0.00)->comment('还款金额');
            $table->string('operator')->default('')->comment('操办人');
            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `mortgage_logs` comment '按揭记录表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('mortgage_logs');
    }
}
